/**
 * 
 */
package com.gmail.sabuj.career.qna.core;

/**
 * @author Sabuj Das | sabuj.das@gmail.com
 * 
 */
public class Tree<T extends Comparable<T>> {

	private Node root;

	private class Node {
		private T value;
		private Node left;
		private Node right;

		/**
		 * @param value
		 */
		public Node(T value) {
			this.value = value;
		}

		public T getValue() {
			return value;
		}

		public void setValue(T value) {
			this.value = value;
		}

		public Node getRight() {
			return right;
		}

		public void setRight(Node right) {
			this.right = right;
		}

	}

	public void add(T value){
		if(root == null){
			root = new Node(value);
			return;
		}
		
	}

	public T getMaxValue() {
		final Node nodeMax = new Node(null);
		inorderMax(root, nodeMax);
		return nodeMax.value;
	}

	public void inorderMax(Node node, final Node nodeMax) {
		if (node == null)
			return;
		
		inorderMax(node.left, nodeMax);

		if (node.value.compareTo(nodeMax.value) >= 1)
			nodeMax.value = node.value;
		
		inorderMax(node.right, nodeMax);

	}

}
